package com.bawei.module_home.discovery.adapter.provider

import android.widget.TextView
import androidx.databinding.DataBindingUtil
import com.bawei.module_home.R
import com.bawei.module_home.databinding.HomeItemTitleLeftRightViewBinding
import com.bawei.module_home.discovery.entity.DiscoveryEntity
import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @Author : yaotianxue
 * @Time : On 2023/5/30 09:09
 * @Description : TitleProvider
 */
class TitleProvider(override val itemViewType: Int, override val layoutId: Int) :BaseItemProvider<DiscoveryEntity.Item>() {
    override fun convert(helper: BaseViewHolder, item: DiscoveryEntity.Item) {
//        var tvTitle = helper.getView<TextView>(R.id.tv_title)
//        var tvActionTitle = helper.getView<TextView>(R.id.tv_action_title)
//        tvTitle.text = item.data.text.toString()
//        tvActionTitle.text = item.data.rightText.toString()
        if(item != null){
            helper.getBinding<HomeItemTitleLeftRightViewBinding>()?.item = item
            helper.getBinding<HomeItemTitleLeftRightViewBinding>()?.executePendingBindings()
        }
    }

    override fun onViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        DataBindingUtil.bind<HomeItemTitleLeftRightViewBinding>(viewHolder.itemView)
    }
}